import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      component: () => import("../views/index.vue"),
      children: [
        {
          path: "/home",
          components: {
            view: () => import("../views/home/tabBar/index/index.vue"),
          },
        },
        {
          path: "/user",
          components: {
            view: () => import("../views/home/tabBar/userInfo/index.vue"),
          },
        },
      ],
    },
    {
      path: "/galInfo",
      component: () => import("../views/home/page_gal/galInfo/index.vue"),
    },
    {
      path: "/notice",
      component: () => import("../views/home/page/noticeList/index.vue"),
    },
    {
      path: "/message",
      component: () => import("../views/home/page/messageList/index.vue"),
    },
  ],
});

router.beforeEach((_to, _from, next) => {
  if (_to.path == "/") {
    next("/home");
  }

  next();
});

export default router;
